//
//  QcCaseCatalogueController.m
//  QcMedical1
//
//  Created by jiawen Du on 2016/12/23.
//  Copyright © 2016年 jiawen Du. All rights reserved.
//

#import "QcCaseCatalogueController.h"

#define kcasetype @"caseType"
#define kcindex @"index"

@interface QcCaseCatalogueController ()<UITableViewDelegate,UITableViewDataSource>
//tableView
@property (nonatomic, strong) UITableView *tableview;

@property (nonatomic, copy)NSArray *array;

@property (nonatomic, copy)NSArray *imgIcon;

@end

NSString *CatalogueCell = @"gg";
@implementation QcCaseCatalogueController

- (void)viewDidLoad {
    [super viewDidLoad];
   
    [self getData];
    
    [self setupUI];

}

- (void)getData {
    
    NSMutableArray *arr = [NSMutableArray arrayWithObjects:@"肿瘤",@"心血管",@"神经科",@"血液科",@"骨科", nil];
    
    NSMutableArray *img = [NSMutableArray arrayWithObjects:@"zl",@"xyg",@"sj",@"xy",@"gt", nil];
    self.imgIcon = img.copy;
    
    self.array = arr.copy;
}

- (void)setupUI {
 
    self.navigationItem.title = @"疾病类型";
    
    //tableView
    UITableView *tableView = [[UITableView alloc]init];
    
    self.tableview = tableView;
    
    tableView.delegate = self;
    
    tableView.dataSource = self;
    
    [self.view addSubview:tableView];
    
    [tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.edges.equalTo(self.view);
        
    }];
    
    [tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:CatalogueCell];
    
}

- (void)clickRightButton:(UIButton *)button {
    
    
    [self.navigationController popViewControllerAnimated:YES];
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return self.array.count;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    UITableViewCell *cell =[tableView dequeueReusableCellWithIdentifier:CatalogueCell forIndexPath:indexPath];
    
    cell.textLabel.text = self.array[indexPath.row];
    
    cell.imageView.image = [UIImage imageNamed:self.imgIcon[indexPath.row]];
    cell.textLabel.font = [UIFont fontWithName:@"CloudShuiZhuGBK" size:15];
    return cell;
    
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
    
    NSString *lb = self.array[indexPath.row];
    
    NSString *index = [NSString stringWithFormat:@"%ld",indexPath.row + 1];

    //发通知
    [[NSNotificationCenter defaultCenter] postNotificationName:kcasetype object:lb];
    
    [[NSNotificationCenter defaultCenter] postNotificationName:kcindex object:index];
    
    [self.navigationController popViewControllerAnimated:YES];
    
}




@end
